import request from "@/utils/request";

//查询扁平化数据
export function getCategories() {
  return request({
    url: '/category/hierarchy',
    showSuccessMessage: false, // 自定义参数：不显示成功提示
  })
}

//查询树状数据
export function getCategoriesTree(page) {
  return request({
    url: '/category/tree',
    params: page,
    showSuccessMessage: false, // 自定义参数：不显示成功提示
  })
}

//查询级联选择器数据
export function getCategoriesCascader() {
  return request({
    url: '/category/cascader',
    showSuccessMessage: false, // 自定义参数：不显示成功提示
  })
}

//添加分类数据
export function addCategory(category) {
  return request({
    url: '/category',
    method: 'POST',
    data: category
  })
}

//删除分类数据
export function romoveCategory(categoryId) {
  return request({
    url: `/category/${categoryId}`,
    method: 'DELETE'
  })
}

//修改分类数据
export function editCategory(categoryId, category) {
  return request({
    url: `/category/${categoryId}`,
    method: 'PUT',
    data: category
  })
}
